<?php
require('connect_sql.php');
require('function.php');


session_start();
if(isset($_SESSION['userid']))
{
	if($_POST['userid']==$_SESSION['userid'])
	{
		$cond="";
		foreach ($_POST as $key => $value) {
			if($key!="userid")
			{
				if(is_numeric($value))
				{
					$cond=$cond.$key."  = ".$value." ,";
				}
				else
				{
					$cond=$cond.$key."  = '".$value."',";
				}
			}
		}
		$cond=substr($cond,0,-1);
		$re=updatef('usertable',$cond,'userid',$_POST['userid']);
		if($re)
		{
			echo "修改成功";
		}
		else
		{
			echo "修改失败";
		}

	}
	else 
	{
		echo "你不允许进行修改";
	}	
}
else
{
	echo "请登陆";
}

?>